// 引入axios实例对象
import requestApi from '@/utils/request'

// 用户登录===============login模块
export const login = (data) => {
    return requestApi({
        method: 'POST',
        url: '/app/v1_0/authorizations',
        data
    })
}

// 发送验证码=================login模块
export const getSmsCode = mobile => {
    return requestApi({
        method: 'GET',
        url: `/app/v1_0/sms/codes/${mobile}`
    })
}

// 获取用户自己的信息=================user模块
export const getUserData = () => {
    return requestApi({
        method: 'GET',
        url: `/app/v1_0/user`
    })
}


// 获取用户个人资料=================editUser模块
export const getUserProfile = (target = null) => {
    return requestApi({
        method: 'GET',
        url: `/app/v1_0/user/profile`,
        data: {
            target
        }
    })
}

// 编辑用户个人资料（包含实名认证）========
export const updateProfile = (data) => {
    return requestApi({
        method: 'PATCH',
        url: `/app/v1_0/user/profile`,
        data
    })
}



// 编辑用户照片资料（头像、身份证照片）=====
export const updateUserPhoto = (data) => {
    return requestApi({
        method: 'PATCH',
        url: `/app/v1_0/user/photo`,
        data
    })
}

// 获取用户频道列表=================home模块
export const getUserChannels = () => {
    return requestApi({
        method: 'GET',
        url: `/app/v1_0/user/channels`
    })
}


// 获取首页新闻列表=================article-list模块
export const getArticle = params => {
    return requestApi({
        method: 'GET',
        url: `/app/v1_1/articles`,
        params
    })
}


// 获取所有的频道=================article-edit模块
export const getAllChannels = () => {
    return requestApi({
        method: 'GET',
        url: `/app/v1_0/channels`,
    })
}

//删除指定用户频道=================article-edit模块
export const delMyChannels = (target) => {
    return requestApi({
        method: 'DELETE',
        url: `/app/v1_0/user/channels/${target}`,
    })
}

//获取用户搜索历史=================search模块
export const getMysearch = () => {
    return requestApi({
        method: 'GET',
        url: `/app/v1_0/search/histories`,
    })
}



//获取用户搜索建议=================search-associate模块
export const searchAssociate = (q) => {
    return requestApi({
        method: 'GET',
        url: `/app/v1_0/suggestion`,
        params: {
            q
        }
    })
}


//获取搜索结果=================search-result模块
export const searchResultAjax = (params) => {
    return requestApi({
        method: 'GET',
        url: `/app/v1_0/search`,
        params
    })
}


//获取文章详情=================article-info模块
export const getArticleInfoData = (id) => {
    return requestApi({
        method: 'GET',
        url: `/app/v1_0/articles/${id}`,
    })
}




//关注用户=================guanzhubtn模块
export const addGuangZhu = (target) => {
    return requestApi({
        method: 'POST',
        url: `/app/v1_0/user/followings`,
        data: {
            target
        }
    })
}

//取消关注用户=================guanzhubtn模块
export const deleteGuanZhu = (target) => {
    return requestApi({
        method: 'DELETE',
        url: `/app/v1_0/user/followings/${target}`,
    })
}


// 获取评论或评论回复
export const getArticleComments = (params) => {
    return requestApi({
        method: 'GET',
        url: `/app/v1_0/comments`,
        params
    })
}
// 对评论或评论回复点赞
export const comment_reply_dianzan = (target) => {
    return requestApi({
        method: 'POST',
        url: `/app/v1_0/comment/likings`,
        data: {
            target
        }
    })
}

// 取消对评论或评论回复点赞
export const comment_reply_delDianzan = (target) => {
    return requestApi({
        method: 'DELETE',
        url: `/app/v1_0/comment/likings/${target}`,
    })
}


// 添加评论或评论回复

export const add_comment_reply_ajax = (data) => {
    return requestApi({
        method: 'POST',
        url: `/app/v1_0/comments`,
        data
    })
}



// 